<?php
/*========================================= JooSam =========================================/
/																							/
/	Extention:		JooSam																	/
/	Created by:		Broadcastweb.eu - Paules												/
/	Site:			http://www.broadcastweb.eu												/
/	Email:			support@broadcastweb.eu													/
/	Copyright:		2011 - 2012 (c) Broadcastweb.eu											/
/	License:		CC BY-NC-ND 3.0 ~ http://creativecommons.org/licenses/by-nc-nd/3.0/		/
/	File Version:	0003																	/
/																							/
/========================================== JooSam ========================================*/
// Joomla security
defined('_JEXEC') or die;
$samdb = $this->samdb;
echo '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
echo '<songdata>'."\n";
$category = $this->settings->request->category_view;
$songtype = $this->settings->request->songtype;
$search = JRequest::getVar('data', '');
if($search != ''){
	$search = '%'.$search.'%';
	$query = "	SELECT S.ID, S.artist, S.title
				FROM songlist S, categorylist C
				WHERE (S.artist LIKE '".$search."' OR S.title LIKE '".$search."')
				AND C.categoryID IN(".$category.")
				AND S.songtype IN(".$songtype.")
				AND S.ID = C.songID
				ORDER BY S.artist, S.title ASC
			";
	$sqldata = $samdb->getObjectList($query);
	if(is_array($sqldata)){
		foreach($sqldata as $item){
			echo "\t".'<song songid="'.$item->ID.'" artist="'.htmlspecialchars(utf8_encode($item->artist)).'" title="'.htmlspecialchars(utf8_encode($item->title)).'"/>'."\n";
		}
	} else{
		echo "\t".'<song songid="ERROR" msg="'.JText::_('COM_JOOSAM_AJAX_NOFOUND').'"/>'."\n";
	}
} else{
	echo "\t".'<song songid="ERROR" msg="'.JText::_('COM_JOOSAM_AJAX_NOSEARCH').'"/>'."\n";
}
echo '</songdata>'."\n";